package tienmanh.gs.goldminer.sprite;

import org.andengine.opengl.texture.region.ITiledTextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import tienmanh.gs.goldminer.scene.GameScene;

public class ElectricFish extends Object {
	public int xSpeed;
	public boolean checkRun ;
	public int start , end;

	public ElectricFish(float pX, float pY, float pWidth, float pHeight,
			ITiledTextureRegion pTiledTextureRegion,
			VertexBufferObjectManager pVertexBufferObjectManager, int paramInt,
			float paramFloat5, String paramString , int start , int end) {
		super(pX, pY, pWidth, pHeight, pTiledTextureRegion, pVertexBufferObjectManager,
				paramInt, paramFloat5, paramString);
		// TODO Auto-generated constructor stub
		checkRun = true;
	    xSpeed=1;
	    this.start = start;
	    this.end = end;
	}
	
	public void swimFish(){
		setPosition(getX()+xSpeed, getY());
	}
	protected void onManagedUpdate(float paramFloat)
	  {
	    super.onManagedUpdate(paramFloat);
	    if(checkRun && GameScene.isMinerRunning){
	    if (getX() <= start)
	    {
	    	xSpeed = -xSpeed;
	    }
	    else
	    if(getX() >= end - getWidth()){
	    	xSpeed = -xSpeed;
	    }
	    swimFish();
	    }
	  }
	public void unswimFish()
	  {
		  checkRun = false;
	  }
	  public void reswimFish()
	  {
		  checkRun = true;
	  }

}
